/***
 * author: sailing
 * date: 2019/5/16
 * 订单管理
 * ***/
import * as types from "./mutation-types";
import { ActionTree } from "vuex";
import axios from "axios";
import tools from "@/server/tools";
const actions: ActionTree<any, any> = {
  /***
   * 获取订单列表
   * **/
  get_order_list({ state, commit }, params: any) {
    let path = tools.get_url("/wallet/cryptocurrency/order");
    axios
      .get(path, {
        params: params
      })
      .then(function(response) {
        commit("set_order", response.data);
        console.log(response);
      })
      .catch(function(error) {
        console.log(error);
      });
  },

  /***
   * 获取单个订单详情
   * id: xxx  // orderID
   * **/
  get_signal_details({ state, commit }, params: any) {
    let path = tools.get_url("/wallet/cryptocurrency/order");
    axios
      .get(path, {
        params: params
      })
      .then(function(response) {
        commit("set_signal_details", response.data);
      })
      .catch(function(error) {
        console.log(error);
      });
  },

  /***
   * 获取订单详情
   * **/
  get_order_details({ state, commit }, params: any) {
    console.log("params,,,:", params);
    let path = tools.get_url("/wallet/cryptocurrency/orderLog");
    axios
      .get(path, {
        params: params
      })
      .then(function(response) {
        commit("set_details", response.data);
        console.log(response);
      })
      .catch(function(error) {
        console.log(error);
      });
  }
};

export default actions;
